<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>小石头公益 助学管理</title>
<%@ include file="common/_head_include.jsp" %>
<style>
table { border:0px; }
td { border:0px; }
</style>
</head>
<body>
<br/><br/><br/>
<p>请登录系统</p>
<hr/>
<br>
<table>
<tr><td>用户名：</td><td><input type="text" id="loginName"/></td></tr>
<tr><td>密码：</td><td><input type="password" id="password"/></td></tr>
<tr><td align="center" colspan="2"><input type="submit" value="登录" onclick="fnLogin()"></td></tr>
</table>
<p id="txtMessage"></p>


<script type="text/javascript">
function fnLogin() {
	var loginName = $("#loginName").val();
	var password = $("#password").val();
	var postData = {loginName:loginName, password:password};
	var url = location.pathname;
	
	$("#txtMessage").text("正在登录...")
    $.ajax({
        type: "POST",
        url: url,
        data: JSON.stringify(postData),
        dataType: "json",
        contentType:"application/json",
        success: function (resp) {
            if (resp.code == "0") {
            	$("#txtMessage").text("登录成功，跳转到首页");
            	var homeUrl = getAncestorPath(location.pathname,1);
            	location.href = homeUrl;
            } else {
            	$("#txtMessage").text("服务器返回出错信息：\n\n" + resp.message);
            }
        },
        error: function () { alert("Sorry，服务器处理请求出错，请联系IT运维人员。"); }
    });

}
</script>
</body>
</html>